struct Solution {}

fn main() {}

impl Solution {
    pub fn answer_string(word: String, num_friends: i32) -> String {
        if num_friends == 1 {
            return word;
        }
        let max_len: usize = (word.len() as i32 - num_friends + 1) as usize;
        let mut ret: String = "".to_string();
        for idx in 0..word.len() {
            if idx + max_len < word.len() {
                let temp = word[idx..idx + max_len].to_string();
                if ret.le(&temp) {
                    ret = temp;
                }
                continue;
            }
            let temp = word[idx..].to_string();
            if ret.le(&temp) {
                ret = temp;
            }
        }
        ret
    }
}